package com.example.ioc.controller;

import com.example.ioc.config.StudentConfig;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2025/7/9
 * Time: 18:02
 */
@RestController
public class YmlController {

    @Value("${spring.datasource.url}")
    public String url;

    @Value("${spring.datasource.username}")
    public String username;

    @Value("${spring.datasource.password}")
    public String password;
    @Value("${yml.value}")
    public String ymlValue;


    @Autowired
    public StudentConfig studentConfig;

    @PostConstruct
    public void readValue() {
        System.out.println("YmlController.url: " + url);
        System.out.println("YmlController.username: " + username);
        System.out.println("YmlController.password: " + password);
        System.out.println("YmlController.ymlValue: " + ymlValue);
    }


    @RequestMapping("/readObject")
    public String readObject() {
        return studentConfig.toString();
    }
}
